package com.example.user3.demo;



//public class Adapter2 extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//    public static final int TYPE_MERCHANT=2;
//    public static final int TYPE_VIDEO=1;
//    public static final int TYPE_SECKILL=3;
//    public static final int TYPE_BARGIN=4;
//    public static final int TYPE_GOODS=5;
//    public static final int TYPE_COUPON=6;
//    private final int itemWidth;
//    List<CityHomeBean> mDataList;
//    Context mContext;
//    RequestOptions options;
//    public Adapter2(Context context,List<CityHomeBean>  mDataList){
//        this.mContext =context;
//        this.mDataList=mDataList;
//        itemWidth = (ScreenUtils.getScreenWidth(context)-32)/2;
//        inflater=LayoutInflater.from(context);
//        options = RequestOptions
//                .noTransformation()
//                .override(itemWidth,itemWidth);
//    }
//
//
//    private LayoutInflater inflater;
//
//
//
//
//    @NonNull
//    @Override
//    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
//        RecyclerView.ViewHolder viewHolder = null;
//        Log.i("zzy","viewType"+"==="+viewType);
//        View view;
////        switch (viewType) {
////            case TYPE_VIDEO:
////                view= inflater.inflate(R.layout.layout_city_video, viewGroup, false);
////                viewHolder = new ViewHolderVideo(view);
////                break;
////            case TYPE_MERCHANT:
////                view=inflater.inflate(R.layout.layout_city_merchant, viewGroup, false);
////                StaggeredGridLayoutManager.LayoutParams f2= (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
////                f2.height = (int) (itemWidth*0.3);
////                view.setLayoutParams(f2);
////                viewHolder = new ViewHolderMerchant(view);
////                break;
////            case TYPE_SECKILL:
////                view=inflater.inflate(R.layout.item_city_seckill, viewGroup, false);
////                StaggeredGridLayoutManager.LayoutParams f3= (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
////                f3.height =(itemWidth);
////                view.setLayoutParams(f3);
////                viewHolder = new ViewHolderSeckill(view);
////                break;
////            case TYPE_BARGIN:
////                viewHolder = new ViewHolderBargin(inflater.inflate(R.layout.item_city_bargain, viewGroup, false));
////                break;
////            case TYPE_GOODS:
////                viewHolder = new ViewHolderGoods(inflater.inflate(R.layout.item_city_normol_goods, viewGroup, false));
////                break;
//////            case TYPE_COUPON:
//////                viewHolder = new ViewHolderCoupon(inflater.inflate(R.layout.layout_city_coupoun, viewGroup, false));
//////                break;
////        }
//        return viewHolder;
//
//    }
//
//    @Override
//    public long getItemId(int position) {
//        return position;
//    }
//
//    @Override
//    public int getItemViewType(int position) {
//        int viewType =mDataList.get(position).show_type;
//        return  viewType;
////        if(viewType == AdapterVerticalMain.TYPE_VIDEO) {//短视频
////            return R.layout.layout_city_video;
////        }
////        else if(viewType ==AdapterVerticalMain.TYPE_SECKILL){//秒杀
////            return R.layout.item_city_seckill;
////        }
////        else if(viewType ==AdapterVerticalMain.TYPE_MERCHANT){//店铺
////            return R.layout.layout_city_merchant;//
////        }
////        else if(viewType ==AdapterVerticalMain.TYPE_BARGIN){//特价
////            return R.layout.item_city_bargain;
////        }
////        else if(viewType ==AdapterVerticalMain.TYPE_GOODS){//普通商品
////            return R.layout.item_city_normol_goods;
////        }
////        else {//优惠券
////            return R.layout.layout_city_coupoun;
//////                    return R.layout.layout_city_merchant;//
////        }
//    }
//
//
//    @Override
//    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
//        StaggeredGridLayoutManager.LayoutParams f2= (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
//        f2.width =itemWidth;
//        switch (getItemViewType(position)) {
//            case TYPE_VIDEO:
////                StaggeredGridLayoutManager.LayoutParams f= (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
////                f.height = (int) (itemWidth*1.77);
////                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderVideo) holder).setTypeVideo(mDataList.get(position));
//                break;
//            case TYPE_MERCHANT:
////                f2.height = (int) (itemWidth*0.3);
////                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderMerchant) holder).setTypeMerchant(mDataList.get(position));
//                break;
//            case TYPE_SECKILL:
////                f2.height = (int) (itemWidth*1);
////                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderSeckill) holder).setSeckill(mDataList.get(position));
//                break;
//
//            case TYPE_BARGIN:
//                f2.height = (int) (itemWidth*1);
//                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderBargin) holder).setTypeBargin(mDataList.get(position));
//
//                break;
//            case TYPE_GOODS:
//                f2.height = (int) (itemWidth*1);
//                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderGoods) holder).setTypeGoods(mDataList.get(position));
//
//                break;
//            case TYPE_COUPON:
//                f2.height = (int) (itemWidth*0.3);
//                holder.itemView.setLayoutParams(f2);
//                ((ViewHolderCoupon) holder).setTypeCoupon(mDataList.get(position));
//
//                break;
//
//        }
//    }
//
//    @Override
//    public int getItemCount() {
//        return mDataList.size();
//    }
//
//    private class ViewHolderVideo extends RecyclerView.ViewHolder {
//        ImageView imageView;
//        RelativeLayout layout;
////        CircleImageView imageView1;
//        TextView nameText;
//        TextView location;
//        TextView desc;
//        public ViewHolderVideo(View holder) {
//            super(holder);
//             imageView = holder.findViewById(R.id.img);
//           float random= getRandomHeight();
//
//            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
//            layoutParams.width = itemWidth;
//            layoutParams.height = (int)(layoutParams.width*random);
//            imageView.setLayoutParams(layoutParams);
//             layout =holder.findViewById(R.id.layout);
//            LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) layout.getLayoutParams();
//            layoutParams2.width =itemWidth;
//            layoutParams2.height = (int)(layoutParams2.width*random);
//            layout.setLayoutParams(layoutParams2);
////             imageView1 =holder.findViewById(R.id.icon);
//             nameText=holder.findViewById(R.id.merchant_name);
//             location = holder.findViewById(R.id.location);
//             desc = holder.findViewById(R.id.content);
//        }
//        //视频类型
//        public void setTypeVideo(  CityHomeBean item){
//
//            RequestOptions options = RequestOptions
//                    .noTransformation()
//                    .override(itemWidth,itemWidth);
//            GlideUtil.getInstance().getLoad2(mContext, item.video_img, imageView,options);
//            nameText.setText(item.nickname);
//            desc.setText(item.content);
//            if(TextUtils.isEmpty(item.content)){
//                desc.setVisibility(View.GONE);
//            }else{
//                desc.setVisibility(View.VISIBLE);
//            }
//        }
//
//        public float getRandomHeight(){
//            return (float) Math.floor(Math.random()*(5-1+1))+1;
//        }
//    }
//
//    private class ViewHolderMerchant extends RecyclerView.ViewHolder {
//        TextView location;
//        TextView typeText;
//        TextView nameText;
//        TextView addressText;
//        ImageView imageView;
//        public ViewHolderMerchant(View inflate) {
//            super(inflate);
//            ImageView imageView= inflate.findViewById(R.id.merchant_image);
//            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) imageView.getLayoutParams();
//            layoutParams.width = itemWidth;
//            layoutParams.height = ScreenUtils.dip2px(mContext,90);
//            imageView.setLayoutParams(layoutParams);
//             location = inflate.findViewById(R.id.location);
//             typeText=inflate.findViewById(R.id.merchant_type);
//             nameText=inflate.findViewById(R.id.merchant_name);
//             addressText=inflate.findViewById(R.id.merchant_address);
//        }
//        //商户类型
//        private void setTypeMerchant(CityHomeBean item){
//            GlideUtil.getInstance().getLoad2(mContext, item.getPic_cover(), imageView,options);
//
//
//
//
//            if(item.sort_name!=null){
//                typeText.setText(item.first_sort_name+"-"+item.sort_name);
//            }else{
//                typeText.setText(item.first_sort_name);
//            }
//
//
//            nameText.setText(item.getShop_name());
//
//
//            addressText.setText(item.shop_address);
//
//        }
//    }
//
//    private class ViewHolderSeckill extends RecyclerView.ViewHolder {
//
//        ProgressBar progressBar;
//        TextView xianliang;
//        TextView name;
//        TextView money;
//        TextView type1;
//        TextView type2;
//        TextView merchant_name;
//        TextView location;
//        TextView layout_start_text;
//        RelativeLayout layout_count;
//        public ViewHolderSeckill(View holder) {
//            super(holder);
//             progressBar= holder.findViewById(R.id.progress);
//             xianliang =holder.findViewById(R.id.xianliang);
//             name = holder.findViewById(R.id.name);
//             money =holder.findViewById(R.id.seckill_text);
//             type1 = holder.findViewById(R.id.type1);
//             type2 = holder.findViewById(R.id.type2);
//             merchant_name = holder.findViewById(R.id.merchant_name);
//             location = holder.findViewById(R.id.location);
//             layout_start_text  =holder.findViewById(R.id.layout_start_text);
//             layout_count =holder.findViewById(R.id.layout_count);
//        }
//        //秒杀
//        private void setSeckill( CityHomeBean item){
//
//
//
////            GlideUtil.getInstance().getLoad2(mContext, item.getPic_cover(), squareImageView,options);
//
//            //商品名称
//
//            name.setText(item.getGoods_name());
//
//
//            String bargain_price = item.getSecond_price();
//            String desc ="秒杀价: ¥";
//            money.setText("ss");
//
//
//            if (item.dispatching_type == 1) {
//                type1.setVisibility(View.VISIBLE);
//                type2.setVisibility(View.GONE);
//            } else if (item.dispatching_type == 2) {
//                type1.setVisibility(View.GONE);
//                type2.setVisibility(View.VISIBLE);
//            } else if (item.dispatching_type== 3) {
//                type1.setVisibility(View.VISIBLE);
//                type2.setVisibility(View.VISIBLE);
//            } else {
//                type1.setVisibility(View.GONE);
//                type2.setVisibility(View.GONE);
//            }
//
//
//
//
//
//            merchant_name.setText(item.getShop_name());
//
//
//
//            if(item.getStock()!=0){
//                BigDecimal b   =   new   BigDecimal((float)(item.getStock()-item.getSecond_stock())/item.getStock());
//                double   f1   =   b.setScale(2,   BigDecimal.ROUND_HALF_UP).doubleValue();
//                int progress= (int) (f1*100);
//                progressBar.setProgress(progress);
//            }
//
//        }
//
//    }
//
//    private class ViewHolderBargin extends RecyclerView.ViewHolder {
//        TextView name;
//        TextView money_text;
//        TextView saleText;
//        TextView oldPrice;
//        TextView type1;
//        TextView type2;
//        TextView merchant_name;
//        TextView location;
//        ImageView tejiaImage;
//        public ViewHolderBargin(View inflate) {
//            super(inflate);
//             tejiaImage=inflate.findViewById(R.id.tejia_image);
//             name = inflate.findViewById(R.id.name);
//             money_text = inflate.findViewById(R.id.money_text);
//             oldPrice = inflate.findViewById(R.id.money_old_text);
//             type1 = inflate.findViewById(R.id.type1);
//             type2 = inflate.findViewById(R.id.type2);
//             merchant_name = inflate.findViewById(R.id.merchant_name);
//             location = inflate.findViewById(R.id.location);
//        }
//        //特价商品
//        private void setTypeBargin(  CityHomeBean item){
//
//
//
//
//            tejiaImage.setVisibility(View.GONE);
//            //商品名称
//
//            name.setText(item.getGoods_name());
//            //促销价
//
//            String bargain_price = item.bargain_price;
//            String desc ="¥ ";
//
//            //销售数量
//
//            saleText.setText(item.getStock());
//
//
//            //原价
//
//            oldPrice.setText("¥" + item.getPrice());
//            oldPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
//
//
//
//            if (item.getDispatching_type() == 1) {
//                type1.setVisibility(View.VISIBLE);
//                type2.setVisibility(View.GONE);
//            } else if (item.getDispatching_type() == 2) {
//                type1.setVisibility(View.GONE);
//                type2.setVisibility(View.VISIBLE);
//            } else if (item.getDispatching_type() == 3) {
//                type1.setVisibility(View.VISIBLE);
//                type2.setVisibility(View.VISIBLE);
//            } else {
//                type1.setVisibility(View.GONE);
//                type2.setVisibility(View.GONE);
//            }
//
//
//            merchant_name.setText(item.getShop_name());
//
//
//        }
//    }
//
//    private class ViewHolderGoods extends RecyclerView.ViewHolder {
//        ImageView tejiaImage;
//        TextView name;
//        TextView money_text;
//        TextView oldPrice;
//        public ViewHolderGoods(View inflate) {
//            super(inflate);
//            tejiaImage=inflate.findViewById(R.id.tejia_image);
//             name = inflate.findViewById(R.id.name);
//             money_text = inflate.findViewById(R.id.money_text);
//            oldPrice = inflate.findViewById(R.id.money_old_text);
//        }
//        private void setTypeGoods( CityHomeBean item){
//            tejiaImage.setVisibility(View.GONE);
//            //商品名称
//            name.setText(item.getGoods_name());
//            //促销价
//
//            //原价
//
//            oldPrice.setVisibility(View.GONE);
//            String price = item.getPrice();
//            String desc ="¥ ";
//
//            oldPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
//
//
//        }
//    }
//
//    private class ViewHolderCoupon extends RecyclerView.ViewHolder {
//        TextView moneyT,coupon_lingqu_text,merchant_name,location;
//        public ViewHolderCoupon(View inflate) {
//            super(inflate);
//             merchant_name = inflate.findViewById(R.id.merchant_name);
//             merchant_name = inflate.findViewById(R.id.merchant_name);
//             location = inflate.findViewById(R.id.location);
//        }
//        //优惠券
//        public void setTypeCoupon( CityHomeBean item){
//            moneyT.setText(item.money);
//            if(item.received_num>0){
//                coupon_lingqu_text.setText("进店使用");
//            }else{
//                coupon_lingqu_text.setText("立即领取");
//            }
//            merchant_name.setText(item.getShop_name());
//
//        }
//
//    }
//
//
//
//
//
//
//}
